package com.oak.designmode._07_proxyParttern.CGLibProxy;


import com.oak.designmode._07_proxyParttern.dynamicProxy.DynamicProxyHandler;

import java.util.Date;

/**
 * CGLib代理类
 *
 * @Description  生成目标代理类的子类，覆盖目标类的所有方法
 * @Author guoxy
 * @Date 2019/11/30
 * @Version 1.0
 */
public class Test {
    public static void main(String[] args) {

        CglibProxy cglibProxy = new CglibProxy();
        long startTime = (new Date()).getTime();
        for (int i = 0; i < 100000; i++) {
            demo(cglibProxy);
        }
        long endTime = (new Date()).getTime();
        System.out.println(endTime - startTime);
    }

    public static void demo(CglibProxy cglibProxy) {
        BuyHouse buyHouse = new BuyHouseImpl();
        BuyHouseImpl buyHouseCglibProxy = (BuyHouseImpl) cglibProxy.getInstance(buyHouse);
        buyHouseCglibProxy.buyHouse();
    }
}
